<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>档案管理系统</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <link rel="stylesheet" href="${request.contextPath}/statics/css/bootstrap.min.css">
  <link rel="stylesheet" href="${request.contextPath}/statics/css/font-awesome.min.css">
  <link rel="stylesheet" href="${request.contextPath}/statics/css/AdminLTE.min.css">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="${request.contextPath}/statics/css/all-skins.min.css">
  <link rel="stylesheet" href="${request.contextPath}/statics/css/main.css">
  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>
<body class="hold-transition login-page" >
<div class="login-box" style="width:800px;" id="rrapp" v-cloak>
  <div class="login-logo">

  </div>
  <!-- /.login-logo -->
  <div class="login-box-body">
<!--      <p class="login-box-msg"> <b style="font-size: 24px">综合档案管理系统</b></p>-->
      <div class="row" style="border: 0px;padding: 40px 2px 0px 2px">
          <div class="col-xs-6" style="padding: 30px;">
              <div v-if="error" class="alert alert-danger alert-dismissible">
                  <h4 style="margin-bottom: 0px;"><i class="fa fa-exclamation-triangle"></i> {{errorMsg}}</h4>
              </div>
              <div class="form-group has-feedback">
                  <input type="text" class="form-control" v-model="username" placeholder="账号">
                  <span class="glyphicon glyphicon-user form-control-feedback"></span>
              </div>
              <div class="form-group has-feedback">
                  <input type="password" class="form-control" v-model="password" placeholder="密码">
                  <span class="glyphicon glyphicon-lock form-control-feedback"></span>
              </div>
              <div class="row" style="border: 0px;">
                  <div class="col-xs-4">
                      <div class="checkbox icheck">
                      </div>
                  </div>
                  <!-- /.col -->
                  <div class="col-xs-4">
                      <button type="button" class="btn btn-primary btn-block btn-flat" @click="login">登录</button>
                  </div>
                  <!-- /.col -->
              </div>
          </div>
          <div class="col-xs-6" style="padding-left: 30px;border-left: 1px solid #D8D9DB ">
              <img class="img-responsive"
                   src="${request.contextPath}/statics/images/logo.jpg"
                   alt="">
          </div>
      </div>
      <div class="row" style="border: 0px;">
          <div class="col-xs-12 lg_bottom_top" style="font-size: 14px">
              <a href="/dangan/file/downloadChrome" target="_blank" class="btn-link" style="font-size:16px;">最新chorme浏览器下载</a>
          </div>
          <div class="col-xs-12 lg_bottom_bottom">
              <span>@2015. All Rights Reserved</span>
          </div>
      </div>

    <!-- /.social-auth-links -->
  </div>
  <!-- /.login-box-body -->
</div>

<!-- /.login-box -->

<script src="${request.contextPath}/statics/libs/jquery.min.js"></script>
<script src="${request.contextPath}/statics/libs/vue.min.js"></script>
<script src="${request.contextPath}/statics/libs/bootstrap.min.js"></script>
<script src="${request.contextPath}/statics/libs/jquery.slimscroll.min.js"></script>
<script src="${request.contextPath}/statics/libs/fastclick.min.js"></script>
<script src="${request.contextPath}/statics/libs/app.js"></script>
<style type="text/css">
    .lg_bottom_top {
        margin-top: 15px;
        font-size: 12px;
        color: #A09FA0;
        text-align: center;
        line-height: 30px;
    }
     .lg_bottom_bottom {
        font-size: 12px;
        color: #848484;
        text-align: center;
        line-height: 30px;
    }
</style>
<head>

<script type="text/javascript">
$(function () {
    var explorer = navigator.userAgent;
    if (explorer.indexOf("Chrome") >= 0) {

    }else{
        if (getChromeVersion()) {
            var version = getChromeVersion();
            if (version < 70) {
                window.open('/dangan/file/downloadChrome');
            }
        }
    }
})
function getChromeVersion() {
    var arr = navigator.userAgent.split(' ');
    var chromeVersion = '';
    for (var i = 0; i < arr.length; i++) {
        if (/chrome/i.test(arr[i]))
            chromeVersion = arr[i]
    }
    if (chromeVersion) {
        console.log("chrome version",Number(chromeVersion.split('/')[1].split('.')[0]))
        return Number(chromeVersion.split('/')[1].split('.')[0]);
    } else {
        return false;
    }
}
var vm = new Vue({
	el:'#rrapp',
	data:{
		username: '',
		password: '',
		captcha: '',
		error: false,
		errorMsg: '',
		src: 'captcha.jpg'
	},
	beforeCreate: function(){
		if(self != top){
			top.location.href = self.location.href;
		}
	},
	methods: {
		refreshCode: function(){
			this.src = "captcha.jpg?t=" + $.now();
		},
		login: function (event) {
			var data = "username="+vm.username+"&password="+vm.password+"&captcha="+vm.captcha;
			$.ajax({
				type: "POST",
			    url: "sys/login",
			    data: data,
			    dataType: "json",
			    success: function(result){
					if(result.code == 0){//登录成功
                        window.localStorage.setItem("login",true)
                        window.localStorage.setItem("user",JSON.stringify(result.user))
                        window.localStorage.setItem("username",result.user.username)
						parent.location.href ='/dangan/modules/dangan/danganIndex.html';
					}else{
                        window.localStorage.setItem("login",false)
						vm.error = true;
						vm.errorMsg = result.msg;
						vm.refreshCode();
					}
				}
			});
		},

	}
});
</script>
</body>
</html>
